package interaction.game;

import interaction.data.DataSource;
import interaction.drawable.Drawable;
import processing.core.*;

public class ScoreItem implements GameObject {
	private Hero hero;
	private PFont font;
	private DataSource<Integer> score = new DataSource<Integer>(0);
	
	public ScoreItem (PFont font, Hero hero) {
		this.font = font;
		this.hero = hero;
	}
	
	public DataSource<Integer> getDataSource() {
		return score;
	}
	
	public int getScore()
	{
		return score.get();
	}

	public void addScore(int s){
		score.set(getScore() + s);
	}
	
	public void resetScore(){
		score.set(0);
	}
	
	public void draw(PGraphics g){
		g.textMode(processing.core.PFont.SCREEN);
		g.textFont(this.font);
		g.fill(0);
		g.text("Score: " + getScore(), 30, 80);
	}

	public void update() {
		addScore((int) hero.getVelocity().x);
	}
}
